/*
 * Copyright 2000 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _WT_EXECUTE_H
#define _WT_EXECUTE_H

#include "WtContext.h"

typedef struct WtExecutionStateT
{
  WtContext *context;
  Tcl_Interp *interp;
  Tcl_Obj *requestedPath;
  Tcl_Obj *targetPath;
  Tcl_Obj *namesp;
  Tcl_Obj *genCode;
} WtExecutionState;

void WtInitExecState(WtExecutionState *execState, WtContext *w, Tcl_Interp *interp);
void WtDeleteExecState(WtExecutionState *execState);
int WtFindAndExecuteFile(WtContext *w, Tcl_Obj *requestedPath, Tcl_Interp *interp);
Tcl_Obj *WtFindFile(WtExecutionState *execState);
Tcl_Obj *WtResolvePath(WtContext *w, Tcl_Obj *requestedPath, Tcl_Obj *dirs);
int WtExecuteFile(WtExecutionState *execState);
Tcl_Obj *WtReadFile(Tcl_Obj *path, int *bytes, Tcl_Interp *interp);
int WtExecuteString(WtExecutionState *execState, Tcl_Obj *string, int len);
int WtParseString(WtExecutionState *execState, Tcl_Obj *string, int len);
void WtParserAddCode(WtExecutionState *execState, char *buf, int len);
int WtParserAddExpr(WtExecutionState *execState, char *buf, int len);
int WtParserAddContent(WtExecutionState *execState, char *buf, int len);
int WtExecuteRequest(WtContext *w, const char *requestedPath);
Tcl_Obj *WtGetCurrentFrame(WtContext *w, Tcl_Interp *interp);
int WtSetCurrentFrame(WtContext *w, Tcl_Obj *frame, Tcl_Interp *interp);
int WtSetFrameState(WtContext *w, Tcl_Interp *interp, const char *state);
int WtSetFrameError(WtContext *w, Tcl_Interp *interp);
void WtInitPageCommands(Tcl_Interp *interp);
int WtIncludeCmd(ClientData clientData, Tcl_Interp *interp,
  int objc, Tcl_Obj *const objv[]);
int WtIncludeStringCmd(ClientData clientData, Tcl_Interp *interp,
  int objc, Tcl_Obj *const objv[]);
int WtPageIndexCmd(ClientData clientData, Tcl_Interp *interp,
  int objc, Tcl_Obj *const objv[]);
int WtStackCmd(ClientData clientData, Tcl_Interp *interp,
  int objc, Tcl_Obj *const objv[]);
int WtLoaderInfoCmd(ClientData clientData, Tcl_Interp *interp,
  int objc, Tcl_Obj *const objv[]);

#endif /* !_WT_EXECUTE_H */
